package infra;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectionUtil {

	public static Connection getConnection() {
		String url = "jdbc:hsqldb:dados/pedidos";
		Connection con = null;
		try {
			Class.forName("org.hsqldb.jdbcDriver");
			con = DriverManager.getConnection(url, "sa", "");
		} catch (ClassNotFoundException e) {
			System.err.println("Não achou o Driver");
		} catch (SQLException e) {
			System.err.println("Falha ao Conectar");
		} finally {
			//System.out.println("Tudo certo!");
		}
		return con;
	}
	
	public static void close(Connection con) throws SQLException {
		con.createStatement().executeUpdate("shutdown");
		con.close();
	}
	
}
